import Vue from 'vue'
import Vuex from './kvuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    counter: 0
  },
  mutations: {
    add(state) {
      state.counter++
    }
  },
  actions: {
    add({commit}){
      setTimeout(() => {
        commit('add')
      }, 3000)
       
    }
  },
  modules: {
  },
  getters: {
    doubleCounter(state) {
      const _v = state
      console.log(_v)
      return state.counter * 2   
    }
  },
})
